package cn.edu.sig.controller;


import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import cn.edu.sig.bean.CurrentPage;
import cn.edu.sig.bean.Style;
import cn.edu.sig.service.StyleService;

@Controller
public class StyleController {
	
	@Resource(name="styleService")
	private StyleService styleService;
	
	@RequestMapping(value="styleList.html",method = RequestMethod.GET)
	public String findAllById(
			@RequestParam(value="styleId" ,required = true)Integer styleId,
			@RequestParam(value="pageNumber" ,required = true)Integer page,
			Model model){
		
		
		CurrentPage<Style> list = styleService.findAllById(styleId,page,5);
		model.addAttribute("lastId",list.getPageItems().size());
		model.addAttribute("list", list);
		model.addAttribute("parent", list.getPageItems().get(0).getStyle());
		return "/admin/styleList";
	}
	
}
